﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Storage;
using Windows.Storage.Streams;

namespace Site2AppWP8.Template
{
    public static class UtilitiesModule
    {
        public static async Task<string> ReadScriptAsync(string filePath)
        {
            Uri uri = new Uri(filePath);
            var script = await StorageFile.GetFileFromApplicationUriAsync(uri);

            var stream = await script.OpenAsync(FileAccessMode.Read);

            var inputStream = stream.GetInputStreamAt(0);

            var reader = new DataReader(inputStream);

            await reader.LoadAsync((uint)(stream.Size));

            var contents = reader.ReadString((uint)(stream.Size));

            return contents;
        }
    }
}
